package com.neusoft.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.crm.entity.Emp;
import com.neusoft.crm.mapper.EmpMapper;
import com.neusoft.crm.service.IEmpService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neusoft.crm.tools.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.management.Query;
import java.sql.Wrapper;
import java.util.List;

/**
 * <p>
 * 员工信息表 服务实现类
 * </p>
 *
 * @author lplpok
 * @since 2023-06-18
 */
@Service
public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements IEmpService {
    @Autowired
    private EmpMapper empMapper;
    @Override
    public CommonResult login(Emp emp) {
        QueryWrapper<Emp> w = new QueryWrapper<>();
        w.eq("logid",emp.getLogid());
        w.eq("logpwd",emp.getLogpwd());
        Emp e = empMapper.selectOne(w);
        //Emp e = empMapper.login(emp);
        if (e == null){
            return new CommonResult(null,204);
        }
        return new CommonResult(e);
    }

    @Override
    public CommonResult getListdata(String select,String inputvalue) {
        QueryWrapper<Emp> M = new QueryWrapper<>();
        M.like(select,inputvalue);
        List<Emp> list = list(M);
        if(list == null || list.size() == 0){
            return new CommonResult(null,204);
        }
        return new CommonResult(list);
    }

    @Override
    public CommonResult getresponsible(String areano) {
        return null;
    }
}
